package com.sdwl.brcl.controller;


import com.sdwl.brcl.service.ChainSysService;
import com.sdwl.brcl.view.ServerResponse;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api(tags = "区块链系统调用")
@RestController("/chain-sys")
public class BusinessParameterController {

    @Resource
    private ChainSysService chainSysService;

    @PostMapping("/saveContract")
    public ServerResponse<String> saveContract(@RequestParam("account") String account,
                                               @RequestParam("url") String url,
                                               @RequestPart("multipartFile") MultipartFile multipartFile,
                                               @RequestParam(value = "contractAddress", required = false) String contractAddress) throws Exception {

        return ServerResponse.createBySuccess(chainSysService.createContract(account,url,multipartFile,contractAddress));
    }
}
